package com.kingwang.training.designpattern.memento.bo.text;

/**
 * @author King
 */
public class RedoCommand implements Command {
    private TextMementoTaker mementoTaker;

    private TextEditor editor;

    public RedoCommand(TextMementoTaker mementoTaker, TextEditor editor) {
        this.mementoTaker = mementoTaker;
        this.editor = editor;
    }

    @Override
    public void execute() {
        TextMemento memento = this.mementoTaker.getRedoMemento();

        if (memento != null) {
            this.editor.restoreFromMemento(memento);
        }
    }
}
